<template>
	<view class="team_page clearfix">

		<!--end head-->
		<!-- 	<block v-if="userInfo.teamPartnerStatus">
			<hasTeam ref="hasTeam"></hasTeam>
		</block>
		<block v-else>
			<noJoinTeam @refresh="refresh" ref="noJoinTeam" v-if="userInfo.isTeam"></noJoinTeam>
			<noTeam @refresh="refresh" ref="noTeam" v-else></noTeam>
		</block> -->
		<teamInfo ref="teaminfo"></teamInfo>
	</view>
</template>

<script>
	import hasTeam from "./child/hasTeam.vue";
	import noTeam from "./child/noTeam.vue";
	import noJoinTeam from "./child/noJoinTeam.vue";
	import teamInfo from './child/team-info.vue'
	import {
		mapState,
		mapMutations
	} from "vuex";
	export default {
		components: {
			hasTeam,
			noTeam,
			noJoinTeam,
			teamInfo
		},
		computed: {
			...mapState(["userInfo"]),
		},

		onShow() {
			this.token=uni.getStorageSync('token');
			// console.log(this.$refs.teaminfo)
			// console.log(this.userInfo)
			if(this.token){
				if (this.userInfo.empClass == 1) {
					//全民经纪人
					this.$nextTick(() => {
						this.$refs.teaminfo.init();
					})
				} else {
					//内部员工
					uni.showModal({
						title: '提示',
						content: '内部员工暂无团队',
						showCancel: false,
						success: (res) => {
							if (res.confirm) {
								uni.switchTab({
									url: '/pages/index/index',
								})
							}
						}
					})
				}
			}else{
				 uni.showModal({
				        title: '提示',
				        content: '请先登录',
				        showCancel: false,
				        success: (res) => {
				          if (res.confirm) {
				            uni.navigateTo({
				              url: '/pages/login/index',
				            })
				          }
				        }
				      })
			}
			
			


			// this.init();
		},
		data() {
			return {
				// 	obj: null
			}
		},
		onReachBottom: function() {
			/* console.log("页面底部");
			let usrInf = JSON.parse(JSON.stringify(this.userInfo))
			let that = this;
			if (usrInf.teamPartnerStatus) {

			} else if (usrInf.isTeam) {

			} else {
				this.$refs.noTeam.onRe()
			} */
		},
		methods: {
			// async init() {
			// 	let usrInf = JSON.parse(JSON.stringify(this.userInfo))
			// 	//判断是否加入团队
			// 	//判断是否非团长
			// 	console.log(111, usrInf)
			// 	var arr = Object.keys(usrInf);
			// 	if (arr.length != 0 && !usrInf.teamPartnerStatus) {
			// 		//获取是否是团员
			// 		let {
			// 			data
			// 		} = await this.$api.getTeamFresh()
			// 		usrInf.isTeam = data.data.isTeam;
			// 		this.$store.commit("SET_USERINFO", usrInf);
			// 	}
			// 	let that = this;
			// 	if (usrInf.teamPartnerStatus) {
			// 		let obj = that.$refs.hasTeam;
			// 		if (obj) {
			// 			obj.start()
			// 		}
			// 	} else if (usrInf.isTeam) {
			// 		let obj = that.$refs.noJoinTeam;
			// 		if (obj) {
			// 			obj.start()
			// 		}
			// 	} else {
			// 		let obj = that.$refs.noTeam;
			// 		if (obj) {
			// 			obj.start()
			// 		}
			// 	}
			// },
			// //刷新
			// refresh() {
			// 	this.init();
			// },
			// //合伙人
			// hasTeam() {
			// 	this.$refs.hasTeam.start()
			// },
			// //经纪人已加入团队
			// noJoinTeam() {
			// 	this.$refs.noJoinTeam.start()
			// },
			// //经纪人未加入团队
			// noTeam() {
			// 	console.log(123456)
			// 	//this.$refs.noTeam.start()
			// }
		}
	}
</script>

<style scoped lang="scss">
	.team_page {
		background-color: #f8f8f8;
	}
</style>
